<template>
  <div id="wisdomPark-section-v10">
    <!-- <MyHeadline title="知识库" :islink="false" /> -->
    <MyCell>
      <div class="content">
        <!-- <HtEcharts :options="echarts_options" /> -->
        <div class="item">
          <el-progress type="circle" :percentage="25" :stroke-width="20" color="#1684fc">
            <template v-slot:default>
              <img src="../../../../assets/imgs/wisdomPark/icon-v1.png" alt="icon-v1" />
            </template>
          </el-progress>
          <div class="value-box">
            <div class="title">本周用电量</div>
            <div class="value">26541W</div>
          </div>
        </div>
        <div class="item">
          <el-progress type="circle" :percentage="25" :stroke-width="20" color="#e99d42">
            <template v-slot:default>
              <img src="../../../../assets/imgs/wisdomPark/icon-v2.png" alt="icon-v2" />
            </template>
          </el-progress>
          <div class="value-box">
            <div class="title">本周用水量</div>
            <div class="value">45541m³</div>
          </div>
        </div>
      </div>
    </MyCell>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { deepCopy } from '@/utils/utils'
import HtEcharts from '@/base-ui/echarts/index'
import MyCell from '@/components/my-cell/index.vue'
import MyHeadline from '@/components/my-headline/index.vue'

import echartsConfig from '../config/wisdomPark-section-v10/echarts-config'
// ========================= 实例

// ========================= 钩子
onMounted(() => {
  echarts_init()
})

// ========================= 数据
// 初始化
const echarts_init = () => {
  onEcharts_data(12)
}

// echarts 配置
const echarts_options = ref(deepCopy(echartsConfig))

// ========================= 函数
// 随机数
const getRandomInt = (min: number, max: number): number => {
  min = Math.ceil(min)
  max = Math.floor(max)
  return Math.floor(Math.random() * (max - min + 1)) + min
}

// echartsV1数据
const onEcharts_data = (num: number) => {
  const xAxisData: any = []
  const seriesData: any = [
    {
      type: 'bar',
      stack: 'x',
      data: []
    }
  ]
  for (let i = 0; i < num; i++) {
    xAxisData.push(`${i + 1}月`)
    seriesData[0].data.push(getRandomInt(50, 200))
  }
  echarts_options.value.xAxis.data = xAxisData
  echarts_options.value.series = seriesData
}

// ========================= 请求

defineExpose({
  echarts_init
})
</script>

<style scoped lang="less">
#wisdomPark-section-v10 {
  .width_height(100%,100%);
  .content {
    .width_height(100%,100px);
    .D_J_A(space-between,center);
    width: 100%;
    box-sizing: border-box;
    padding: 0 @space_20;
    .item {
      .D_J_A(space-between,center);
      width: calc(100% / 2 - @space_20 / 2);
      .value-box {
        .title {
          .font-S-W-C(14px,400,#fff);
          margin-bottom: 10px;
        }
        .value {
          .font-S-W-C(18px,400,#fff);
        }
      }
    }
  }
}
</style>
